package com.szwistar.common.comm.jsonrpc;

import com.fasterxml.jackson.annotation.JsonIgnore;

public class JsonRpcMessagePingAck extends JsonRpcMessage {
	// 当前时间(ms)
	protected long ms;
	public long getMs() { return ms; }

	public JsonRpcMessagePingAck() {
		super();
		this.msgType = MSG_CALL;
	}

	public JsonRpcMessagePingAck(JsonRpcMessagePing request) {
		super(MSG_PING_ACK, request.getMsgId());
		this.ms = request.getMs();
	}

	/**
	 * 获取响应延时(ms)
	 */
	@JsonIgnore
	public int getDelay() {
		return (int) (System.currentTimeMillis() - ms);
	}

	@Override
	public String toString() {
		return "JsonRpcMessagePingAck [delay=" + getDelay() + ", msgId=" + msgId + "]";
	}
}
